import React from 'react';
import { Routes, Route, Navigate } from 'react-router-dom';
import { MainLayout } from '../components/common/Layout/MainLayout';
import Dashboard from '../pages/Dashboard/Dashboard';
import MemberList from '../pages/Member/MemberList';
import MaterialList from '../pages/Material/MaterialList';
import BorrowList from '../pages/Borrow/BorrowList';
import Profile from '../pages/Profile/Profile';
import ExamplePage from '../test/ExamplePageCommon';
import { AuthGuard } from '../components/common/AuthGuard';
import Login from '../pages/Login/Login';
export function Router() {
  return (
    <Routes>
      {/* 公开路由 - 登录页面 */}
      <Route path="/login" element={<Login />} />

      {/* 受保护的路由 */}
      <Route path="/" element={
        <AuthGuard>
          <MainLayout />
        </AuthGuard>
      }>
        <Route index element={<Navigate to="/dashboard" replace />} />
        <Route path="dashboard" element={<Dashboard />} />
        <Route path="users" element={<MemberList />} />
        <Route path="materials" element={<MaterialList />} />
        <Route path="borrows" element={<BorrowList />} />
        <Route path="profile" element={<Profile />} />
      </Route>

      {/* 默认重定向 */}
      <Route path="*" element={<Navigate to="/dashboard" replace />} />
    </Routes>
  );
}

export default Router;
